package com.cyh.ebptasywar.thread;

import com.cyh.ebptasywar.cell.BaseCell;
import com.cyh.ebptasywar.logic.ExecuteThreadLogic;
import com.cyh.ebptpubjar.entitys.asywork.entity.WorkEntity;
import com.cyh.ebptpubjar.ebptlogger.EbptLogger;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 线程的基类
 */
public class ExecuteThread extends BaseThread implements Runnable{

    @Autowired
    private ExecuteThreadLogic logic;

    private BaseCell cell;

    // 线程类型
    private String threadType;

    // cell名称
    private String cellName;


    /**
     * 执行任务
     * @param workEntity
     * @return
     */
    @Override
    public WorkEntity cellExcute(WorkEntity workEntity){
        return null;
    }
    /**
     * 更新任务结果
     * @param workEntity
     * @return
     */
    @Override
    public void cellUpdate(WorkEntity workEntity){
    }

    @Override
    public void run() {
        WorkEntity workEntity = null;
        try {
            workEntity = logic.getWork(workEntity);
            if(workEntity != null){
                String reqSeqNo = EbptLogger.initEbptLogger(null);
                workEntity = cell.cellExcute(workEntity);
            }else{
                EbptLogger.info(getClass(),"当前线程类型[{}]没有任务",threadType);
            }

        }catch (Exception e){

        }finally {

        }
    }
}
